<?php
/**
 * test
 */

define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');

header('Content-type:text/html;charset=utf8');

/********************自己插了一条数据*************/
function index_get_links(){
    $sql = 'SELECT link_logo, link_name, link_url FROM ' . $GLOBALS['ecs']->table('friend_link') . ' ORDER BY show_order';
    $res = $GLOBALS['db']->getAll($sql);

    $links['img']= array();

    foreach ($res AS $row)
    {
        if (!empty($row['link_logo']))
        {
            $links['img'][] = array('name' => urlencode($row['link_name']),
                                    'url'  => $row['link_url'],
                                    'logo' => $row['link_logo']);
        }
    }
    return $links;
}

  echo urldecode(json_encode(index_get_links()));

  echo $_LANG['shopman_comment'];


/* APPSERVER 抽象类 */
class IndexServer extends APPSERVER
{

    //构造函数
    function __construct()
    {
        
    }

    /**
     * ---------------------------------------------------
     * >接口说明：用户登陆接口
     * <code>
     * URL地址：/index/login
     * 提交方式：POST
     * 参数#1：name, 类型：STRING，必须：YES，示例：liyong
     * 参数#2：pass, 类型：STRING，必须：YES，示例：liyong
     * ---------------------------------------------------
     */
    public function loginAction()
    {
       // return login customer
        $name = $this->param('name');
        $pass = $this->param('pass');
        if ($name && $pass) {
            $customerDao = $this->dao->load('Core_Customer');
            $customer = $customerDao->doAuth($name, $pass);
            if ($customer) {
                $customer['sid'] = session_id();
                $_SESSION['customer'] = $customer;
                $this->render('10000', 'Login ok', array(
                    'Customer' => $customer
                ));
            }
        }
        // return sid only for client
        $customer = array('sid' => session_id());
        $this->render('14001', 'Login failed', array(
            'Customer' => $customer
        ));
    }

    /**
     * ----------------------------------------------------
     * > 接口说明：用户登出接口
     * <code>
     * URL地址：/index/logout
     * 提交方式：POST
     * 参数#1：sid，类型：STRING，必须：YES，示例：
     * </code>
     * ----------------------------------------------------
     */
    public function logoutAction ()
    {
        $_SESSION['customer'] = null;
        $this->render('10000', 'Logout ok');
    }
}
?>